# Fri May 13 10:04:53 2022 edit
# 字符编码：UTF-8
# R 版本：R 4.2.0 x64 for window 11
# cgh163email@163.com
# 个人笔记不负责任，拎了个梨🍐🍈
#.rs.restartR()
require(rlist)
require(sf)
require(jsonlite)
require(leaflet)
require(leafgl)

rm(list = ls());gc()

# dt <- list.load('http://www.tqyb.com.cn/designs/js/geoJson/GDZC_geo.json')
dt.map <- st_read('http://www.tqyb.com.cn/designs/js/geoJson/GDZC_geo.json')
plot(dt.map[1])
# write_sf(dt.map,'data/zc.geojson')

#leaflet Fri May 13 14:14:23 2022 ------------------------------


leaflet() |>
  # amap() |>

  addTiles(
    'http://rt{s}.map.gtimg.com/realtimerender?z={z}&x={x}&y={y}&type=vector&style=0',
    # 'http://its.map.baidu.com:8002/traffic/TrafficTileService?level={z}&x={x}&y={y}&time=1373790856265&label=web2D&;v=017',
    options = tileOptions(
      tms = TRUE,
      tileSize = 256,
      minZoom = 4,
      maxZoom = 17,
      subdomains = "0123"
    ),
    attribution = '&copy; <a href="https://youmigo.gitee.io/shanghai_nucleic_acid/">youmigo🍐</a>'
  ) |>
  addGlPolygons(data = dt.map,
                color =  topo.colors(nrow(dt.map))
                ,popup = ~name)
#广州市各区  Sat May 14 08:29:45 2022 ------------------------------
URL <- 'http://www.tqyb.com.cn/designs/js/geoJson/BCGZ_geo.json'

dt.map <- list.load(URL)
write_json(dt.map,'data/广州各区界，加密.josn')

#从化 Sat May 14 08:39:42 2022 ------------------------------
url <- 'http://www.tqyb.com.cn/designs/js/geoJson/GDCO_geo.json'

dt.map <- read_json(url)
write_json(dt.map,'data/从化镇街，加密.json')

#白云镇街 Sat May 14 08:45:26 2022 ------------------------------
paste('http://www.tqyb.com.cn/designs/js/geoJson/GDBY_geo.json') |>
  read_json() |>
  write_json(path = 'data/白云区镇街.geojson')

#花都 Sat May 14 08:51:37 2022 ------------------------------
paste('http://www.tqyb.com.cn/designs/js/geoJson/GDHX_geo.json') |>
  read_json() |>
  write_json(path = 'data/花都区镇街.geojson')
#黄埔 Sat May 14 08:51:37 2022 ------------------------------
paste('http://www.tqyb.com.cn/designs/js/geoJson/GDHU_geo.json') |>
  read_json() |>
  write_json(path = 'data/黄埔区镇街.geojson')
#南沙 Sat May 14 08:51:37 2022 ------------------------------
paste('http://www.tqyb.com.cn/designs/js/geoJson/GDNS_geo.json') |>
  read_json() |>
  write_json(path = 'data/南沙区镇街.geojson')
